<?php
/*
+--------------------------------------------------------------------------
|   phpBIZbiz v3.0 full version
|   ========================================
|   by taft@wjl.cn
|   http://www.phpbiz.cn
|   all rights reserved
+---------------------------------------------------------------------------
|
|   > 
|   > 最后修改日期：2005-9-9
|   > 
|
+--------------------------------------------------------------------------
*/
!function_exists('do_login') && exit('Forbidden');
$mes = new message;
class message
{
	function message()
	{
		global $ADMIN,$INCOME,$ADMINER;

		//---------------------------------------
		// Kill globals - globals bad, Homer good.
		//---------------------------------------
		
		$tmp_in = array_merge( $_GET, $_POST, $_COOKIE );
		
		foreach ( $tmp_in as $k => $v )
		{
			unset($$k);
		}

		//---------------------------------------
		// refresh cache
		@unlink("cache/index_cache.php");
	    
		switch($INCOME['code'])
		{
			case 'broad':
		         $this -> broad();
			     break;
		    case 'add':
				 $this -> add_form();
			     break;
			case 'doadd':
				$this -> do_add();
			    break;
			case 'mom':
				$this -> mom_form();
			    break;
			case 'dom':
				$this ->do_mom();
			    break;
			case 'del':
				$this -> do_del();
			    break;
			case 'search':
				$this -> search_form();
			    break;
			case 'dosearch':
				$this -> do_search();
			    break;
			case 'view':
				$this -> view_form();
			    break;
			case 'advice':
				$this->view_advice();
			    break;
			case 'caveat':
				$this -> caveat_list();
			    break;
			case 'process':
				$this -> process_form();
			    break;
			case 'doprocess':
				$this ->do_process();
			    break;
		    case 'delc':
                $this -> del_caveat();
			   break;
			case 'sellerad':		
				$this->seller_ad();
				break;
			case 'selleraddel':
				$this->seller_ad_del();
				break;
			case 'selleradmom':
				$this->seller_ad_mom();
				break;
			case 'selleraddom':
				$this->seller_ad_do_mom();
				break;
			case 'needgoods':		
				$this->need_goods();
				break;
			case 'needgoodsdel':
				$this->need_goods_del();
				break;
			case 'needgoodsmom':
				$this->need_goods_mom();
				break;
			case 'needgoodsdom':
				$this->need_goods_do_mom();
				break;
			default :
		        $this -> broad();
        	     break;

		}

	}

	function broad()
	{
	   global $SKIN,$ADMIN,$DB,$INCOME;

       $ADMIN -> page_title = "管理公告";
	   $ADMIN -> page_instruction ="这里可以管理发布到前台的公告信息。";
	   $start = $INCOME['st'] ? intval( $INCOME['st'] ) : 0;

	   $query = "SELECT * FROM biz_info WHERE info_type = '".INFO_BRD."' ORDER BY info_active_time DESC LIMIT $start,10";

 	   $DB -> db_query( "SELECT count(*) as ct FROM biz_info WHERE info_type = '".INFO_BRD."'");

	   $row_count = $DB -> db_fetch_row();

	   $pages = $SKIN->build_pagelinks( array('TOTAL_POSS'  => $row_count['count'],
											   'PER_PAGE'    => 10,
											   'CUR_ST_VAL'  => $start,
											   'L_SINGLE'    => "一页",
											   'L_MULTI'     => "页：",
											   'BASE_URL'    => $this->base_url."?act=mes"."&code={$INCOME['code']}"
											   )
											);
	   $SKIN->td_header[] = array("公告标题","70%");
	   $SKIN->td_header[] = array("发布时间","18%");
	   $SKIN->td_header[] = array(" ","7%");
	   $SKIN->td_header[] = array(" ","");

	    $ADMIN -> html .= $SKIN -> table_head();
		
		$DB -> db_query($query);
	    
		while ( $r = $DB->db_fetch_row() )
		{
			
			$tm = date("Y-m-d H:i:s",$r['info_active_time']);
			$ADMIN->html .= $SKIN->table_row( array("{$r['info_title']}","{$tm}","<a href=\"?act=mes&code=mom&M_ID={$r['id']}\">修改</a>","<a href=\"?act=mes&code=del&M_ID={$r['id']}\">删除</a>") );
		}

		$ADMIN->html .= $SKIN->td_basic($pages, 'right', 'pformstrip');
		$ADMIN->html .= $SKIN->table_end();
		$ADMIN->output();
		return;
	}

	function add_form()
	{
		global $SKIN,$ADMIN;

		$ADMIN -> page_title = "发布公告";

		$SKIN -> td_header[] =array(" ","30%");
		$SKIN -> td_header[] =array(" ","70%");

		$ADMIN -> html .= $SKIN ->table_head();
		$ADMIN -> html .= $SKIN ->form_head();
		$ADMIN -> html .= $SKIN ->form_input("code","doadd","hidden");

		$ADMIN -> html .= $SKIN ->table_row(array("公告标题",$SKIN -> form_input("info_title")));
		$ADMIN -> html .= $SKIN ->table_row(array("公告内容","<TEXTAREA NAME='info_content' ROWS='10' COLS='40'></TEXTAREA>"));
        $ADMIN -> html .= $SKIN ->form_end("增加");
		$ADMIN -> html .= $SKIN ->table_end();

		$ADMIN -> output();
		return;
	}

	function do_add()
	{
		global $DB,$ADMIN,$INCOME;

		$tm =time();
		$type = INFO_BRD;
		$DB -> db_query( " INSERT INTO `biz_info` ( `info_content` , `info_title` , `info_active_time` ,  `info_type` )  VALUES (  '{$INCOME[info_content]}', '{$INCOME[info_title]}', '{$tm}',  '{$type}' )" );
        
		$ADMIN->record_log("发布新公告");
	    $ADMIN->done_screen("新公告已移发布", "管理公告", "act=mes&code=broad" );
    	return;
	}

	function mom_form()
	{
		global $INCOME,$ADMIN,$SKIN,$DB;

		$id = intval( $INCOME['M_ID'] );

		$DB -> db_query( "SELECT * FROM biz_info WHERE id='".$id."'" );

		if( !$DB -> db_fetch_num() )  $ADMIN-> error("没有返回相关数据。"); 
		
		$m_r = $DB -> db_fetch_row();
		
		$ADMIN -> page_title ="修改公告消息";

		$SKIN -> td_header[] = array( " ","30%");
		$SKIN -> td_header[] = array( " ","");
		
		$ADMIN -> html = $SKIN -> table_head();
		$ADMIN -> html .=$SKIN -> form_head();
		$ADMIN -> html .=$SKIN -> form_input("code","dom","hidden");
        $ADMIN -> html .=$SKIN -> form_input("M_ID","{$m_r['id']}","hidden");
		$ADMIN -> html .=$SKIN -> table_row( array("公告标题",$SKIN->form_input("info_title","{$m_r['info_title']}") ));
        $ADMIN -> html .=$SKIN -> table_row( array("公告内容", "<TEXTAREA NAME='info_content' ROWS='10' COLS='40'>{$m_r['info_content']}</TEXTAREA>" ) );

		$ADMIN -> html .= $SKIN -> form_end("修改");
		$ADMIN -> html .= $SKIN -> table_end();
		$ADMIN -> output();
		return;
	}

	function do_mom()
	{
		global $INCOME,$ADMIN,$DB;

		$id = intval($INCOME['M_ID']);

		$DB -> db_query( "SELECT * FROM biz_info WHERE id='".$id."'" );

		if( !$DB-> db_fetch_num() ) $ADMIN -> error("没有返回相关数据");

		$DB -> db_query( "UPDATE biz_info SET info_title='".$INCOME['info_title']."', info_content='".$INCOME['info_content']."' WHERE id='".$id."'" );

        $ADMIN -> record_log("更新公告");
		$ADMIN -> done_screen( "更新公告成功","管理公告","act=mes&code=broad");
		return;
	}

	function do_del()
	{
		global $INCOME,$DB,$ADMIN;

		$id = intval($INCOME['M_ID']);

		$DB -> db_query( "SELECT * FROM biz_info WHERE id='".$id."'" );

		if( !$DB-> db_fetch_num() ) $ADMIN -> error("没有返回相关数据");


		$DB -> db_query( "DELETE FROM biz_info WHERE id='".$id."'" );
	
	    $ADMIN -> record_log("删除公告");
		$ADMIN -> done_screen("删除公告成功","管理公告","act=mes&code=broad");
		return;
	}
	
	function seller_ad()
	{
	   global $SKIN,$ADMIN,$DB,$INCOME;

       $ADMIN -> page_title = "管理卖家广告";
	   $ADMIN -> page_instruction ="这里可以管理发布到前台的卖家广告。";
	   $start = $INCOME['st'] ? intval( $INCOME['st'] ) : 0;

	   $query = "SELECT * FROM biz_info WHERE info_type = '".INFO_ADV."' ORDER BY info_active_time DESC LIMIT $start,10";

 	   $DB -> db_query( "SELECT count(*) as ct FROM biz_info WHERE info_type = '".INFO_ADV."'");

	   $row_count = $DB -> db_fetch_row();

	   $pages = $SKIN->build_pagelinks( array('TOTAL_POSS'  => $row_count['count'],
											   'PER_PAGE'    => 10,
											   'CUR_ST_VAL'  => $start,
											   'L_SINGLE'    => "一页",
											   'L_MULTI'     => "页：",
											   'BASE_URL'    => $this->base_url."?act=mes"."&code={$INCOME['code']}"
											   )
											);
	   $SKIN->td_header[] = array("广告标题","70%");
	   $SKIN->td_header[] = array("发布时间","18%");
	   $SKIN->td_header[] = array(" ","7%");
	   $SKIN->td_header[] = array(" ","");

	    $ADMIN -> html .= $SKIN -> table_head();
		
		$DB -> db_query($query);
	    
		while ( $r = $DB->db_fetch_row() )
		{
			
			$tm = date("Y-m-d H:i:s",$r['info_active_time']);
			$ADMIN->html .= $SKIN->table_row( array("{$r['info_title']}","{$tm}","<a href=\"?act=mes&code=selleradmom&M_ID={$r['id']}\">修改</a>","<a href=\"?act=mes&code=selleraddel&M_ID={$r['id']}\">删除</a>") );
		}

		$ADMIN->html .= $SKIN->td_basic($pages, 'right', 'pformstrip');
		$ADMIN->html .= $SKIN->table_end();
		$ADMIN->output();
		return;
	}
	
	function seller_ad_del()
	{	
		
		global $INCOME,$DB,$ADMIN;

		$id = intval($INCOME['M_ID']);

		$DB -> db_query( "SELECT * FROM biz_info WHERE id='".$id."'" );

		if( !$DB-> db_fetch_num() ) $ADMIN -> error("没有返回相关数据");


		$DB -> db_query( "DELETE FROM biz_info WHERE id='".$id."'" );
	
	    $ADMIN -> record_log("删除广告");
		$ADMIN -> done_screen("删除广告成功","管理卖家广告","act=mes&code=sellerad");
		return;
	}
	
	function seller_ad_mom()
	{
		global $INCOME,$ADMIN,$SKIN,$DB;

		$id = intval( $INCOME['M_ID'] );

		$DB -> db_query( "SELECT * FROM biz_info WHERE id='".$id."'" );

		if( !$DB -> db_fetch_num() )  $ADMIN-> error("没有返回相关数据。"); 
		
		$m_r = $DB -> db_fetch_row();
		
		$ADMIN -> page_title ="修改卖家广告消息";

		$SKIN -> td_header[] = array( " ","30%");
		$SKIN -> td_header[] = array( " ","");
		
		$ADMIN -> html = $SKIN -> table_head();
		$ADMIN -> html .=$SKIN -> form_head();
		$ADMIN -> html .=$SKIN -> form_input("code","selleraddom","hidden");
        $ADMIN -> html .=$SKIN -> form_input("M_ID","{$m_r['id']}","hidden");
		$ADMIN -> html .=$SKIN -> table_row( array("广告标题",$SKIN->form_input("info_title","{$m_r['info_title']}") ));
        $ADMIN -> html .=$SKIN -> table_row( array("广告内容", "<TEXTAREA NAME='info_content' ROWS='10' COLS='40'>{$m_r['info_content']}</TEXTAREA>" ) );

		$ADMIN -> html .= $SKIN -> form_end("修改");
		$ADMIN -> html .= $SKIN -> table_end();
		$ADMIN -> output();
		return;
	}
	function seller_ad_do_mom()
	{
		global $INCOME,$ADMIN,$DB;

		$id = intval($INCOME['M_ID']);

		$DB -> db_query( "SELECT * FROM biz_info WHERE id='".$id."'" );

		if( !$DB-> db_fetch_num() ) $ADMIN -> error("没有返回相关数据");

		$DB -> db_query( "UPDATE biz_info SET info_title='".$INCOME['info_title']."', info_content='".$INCOME['info_content']."' WHERE id='".$id."'" );

        $ADMIN -> record_log("更新广告");
		$ADMIN -> done_screen( "更新广告成功","管理卖家广告","act=mes&code=sellerad");
		return;
	}
		
	function need_goods()
	{
		global $SKIN,$ADMIN,$DB,$INCOME;

		$ADMIN -> page_title = "管理求购信息";
	   	$ADMIN -> page_instruction ="这里可以管理发布到前台的求购信息。";
	   	$start = $INCOME['st'] ? intval( $INCOME['st'] ) : 0;

	  	$query = "SELECT * FROM biz_info WHERE info_type = '".INFO_REQ."' ORDER BY info_active_time DESC LIMIT $start,10";

 	   	$DB -> db_query( "SELECT count(*) as ct FROM biz_info WHERE info_type = '".INFO_REQ."'");

	   	$row_count = $DB -> db_fetch_row();

	   	$pages = $SKIN->build_pagelinks( array('TOTAL_POSS'  => $row_count['count'],
											   'PER_PAGE'    => 10,
											   'CUR_ST_VAL'  => $start,
											   'L_SINGLE'    => "一页",
											   'L_MULTI'     => "页：",
											   'BASE_URL'    => $this->base_url."?act=mes"."&code={$INCOME['code']}"
											   )
											);
	   	$SKIN->td_header[] = array("信息标题","70%");
	   	$SKIN->td_header[] = array("发布时间","18%");
	   	$SKIN->td_header[] = array(" ","7%");
	   	$SKIN->td_header[] = array(" ","");

	    $ADMIN -> html .= $SKIN -> table_head();
		
		$DB -> db_query($query);
	    
		while ( $r = $DB->db_fetch_row() )
		{
			
			$tm = date("Y-m-d H:i:s",$r['info_active_time']);
			$ADMIN->html .= $SKIN->table_row( array("{$r['info_title']}","{$tm}","<a href=\"?act=mes&code=needgoodsmom&M_ID={$r['id']}\">修改</a>","<a href=\"?act=mes&code=needgoodsdel&M_ID={$r['id']}\">删除</a>") );
		}

		$ADMIN->html .= $SKIN->td_basic($pages, 'right', 'pformstrip');
		$ADMIN->html .= $SKIN->table_end();
		$ADMIN->output();
		return;
	}
	function need_goods_del()
	{	
		
		global $INCOME,$DB,$ADMIN;

		$id = intval($INCOME['M_ID']);

		$DB -> db_query( "SELECT * FROM biz_info WHERE id='".$id."'" );

		if( !$DB-> db_fetch_num() ) $ADMIN -> error("没有返回相关数据");


		$DB -> db_query( "DELETE FROM biz_info WHERE id='".$id."'" );
	
	    $ADMIN -> record_log("删除求购信息");
		$ADMIN -> done_screen("删除求购信息成功","管理求购信息","act=mes&code=needgoods");
		return;
	}
	
	function need_goods_mom()
	{
		global $INCOME,$ADMIN,$SKIN,$DB;

		$id = intval( $INCOME['M_ID'] );

		$DB -> db_query( "SELECT * FROM biz_info WHERE id='".$id."'" );

		if( !$DB -> db_fetch_num() )  $ADMIN-> error("没有返回相关数据。"); 
		
		$m_r = $DB -> db_fetch_row();
		
		$ADMIN -> page_title ="修改求购信息";

		$SKIN -> td_header[] = array( " ","30%");
		$SKIN -> td_header[] = array( " ","");
		
		$ADMIN -> html = $SKIN -> table_head();
		$ADMIN -> html .=$SKIN -> form_head();
		$ADMIN -> html .=$SKIN -> form_input("code","needgoodsdom","hidden");
        $ADMIN -> html .=$SKIN -> form_input("M_ID","{$m_r['id']}","hidden");
		$ADMIN -> html .=$SKIN -> table_row( array("求购信息标题",$SKIN->form_input("info_title","{$m_r['info_title']}") ));
        $ADMIN -> html .=$SKIN -> table_row( array("求购信息内容", "<TEXTAREA NAME='info_content' ROWS='10' COLS='40'>{$m_r['info_content']}</TEXTAREA>" ) );

		$ADMIN -> html .= $SKIN -> form_end("修改");
		$ADMIN -> html .= $SKIN -> table_end();
		$ADMIN -> output();
		return;
	}
	
	function need_goods_do_mom()
	{
		global $INCOME,$ADMIN,$DB;

		$id = intval($INCOME['M_ID']);

		$DB -> db_query( "SELECT * FROM biz_info WHERE id='".$id."'" );

		if( !$DB-> db_fetch_num() ) $ADMIN -> error("没有返回相关数据");

		$DB -> db_query( "UPDATE biz_info SET info_title='".$INCOME['info_title']."', info_content='".$INCOME['info_content']."' WHERE id='".$id."'" );

        $ADMIN -> record_log("更新求购信息");
		$ADMIN -> done_screen( "更新求购信息成功","管理求购信息","act=mes&code=needgoods");
		return;
	}

	function search_form()
	{ 
		global $ADMIN,$SKIN;

		$ADMIN -> page_title = "数据库全文搜索";

		$ADMIN -> page_instruction = "此功能用于对数据库全文不良文字搜索。由于耗费系统资源，请在用户访问量少的时候使用。";

		$SKIN -> td_header[] = array( " ","30%");
        $SKIN -> td_header[] = array( " ","");
		
		$condition = array( "biz_message|message_content"=>"公告或留言内容", "biz_message|message_writer_title"=>"公告或留言标题", "biz_message|message_reply_content"=>"公告或留言回复", "biz_goods|goods_describle"=>"商品描述", "biz_goods|goods_name"=>"商品名称", "biz_shop|shop_describle"=>"店铺描述","biz_shop|shop_name"=>"店铺名称");
		$ADMIN -> html = $SKIN -> table_head();
		$ADMIN -> html .= $SKIN -> form_head();
        $ADMIN -> html .= $SKIN -> form_input("code","dosearch","hidden");

		$ADMIN -> html .= $SKIN -> table_row( array("检索词汇(键入一个关键词或者短语来搜索)", $SKIN->form_input( "words" ) ) );
        $ADMIN -> html .= $SKIN -> table_row( array("选择范围",$SKIN-> multiple_select("condition[]",$condition)));

		$ADMIN -> html .= $SKIN -> form_end("开始搜索");
		$ADMIN -> html .= $SKIN -> table_end();
		$ADMIN -> output();
		return;

	}

	function do_search()
	{
		global $INCOME,$ADMIN,$SKIN,$DB;

		if( !$INCOME[words] ) $ADMIN -> error( "请输入检索关键词" );
		
		$ADMIN -> page_title = "检索结果";

		$SKIN -> td_header[] = array( "记录ID号","25%");
		$SKIN -> td_header[] = array( "记录所在表","25%");
		$SKIN -> td_header[] = array( "记录所在项","25%");
		$SKIN -> td_header[] = array( " ","");
		$ADMIN -> html .= $SKIN -> table_head("结果列表");
		
		$record = 0;

		$condition = $INCOME['condition'];
		foreach( $condition as $k => $v)
		{
			if( $v )
			{
				$c = explode("|",$v);
				
				$pre = explode("_",$c[1]);
				$id = $pre[0]."_id";

				$DB -> db_query( "SELECT * FROM $c[0] WHERE $c[1] LIKE '%".$INCOME['words']."%'");
			    while( $r = $DB -> db_fetch_row() )
				{
					$record++;
					$this_id = $r[$id];
					$ADMIN -> html .= $SKIN -> table_row( array("<center>{$this_id}</center>","<center>tbl_{$c[0]}</center>","<center>{$c[1]}</center>","<center><a href='?act=mes&code=view&ID={$this_id}&TABLE=tbl_{$c[0]}&FIELD={$c[1]}'>查 看</a></center>") );
				}
			
			}
		}
		
		if( ! $record )
		{
			$ADMIN -> html = "";
			$ADMIN -> error("检索结果为0");
			exit;
		}
	    
		$ADMIN -> html .= $SKIN -> table_end();

		$ADMIN -> output();
		return;

	}

	function view_form()
	{
		global $INCOME,$DB;

		$id = intval($INCOME['ID']);
		$tb = explode("_",$INCOME['TABLE']);
		$fd = $INCOME[FIELD];
		$query = " SELECT ".$fd." FROM ".$tb[1]."_".$tb[2]." WHERE ".$tb[2]."_id ='".$id."'";
		$DB -> db_query($query);
		$res = $DB -> db_fetch_row();
		$content = trim($res[0]);
		echo $content=preg_replace( "/\n/" , "<br>", $content );
		return;

	}

	function view_advice()
	{
		global $INCOME,$DB,$ADMIN,$SKIN;

		$DB -> db_query("SELECT * FROM biz_message WHERE message_type=".MESSAGE_BUG_ADV." ORDER BY message_write_date DESC");

		$ADMIN->page_title="用户留言与建议";
	
		$SKIN -> td_header[] = array("姓名","10%");
		$SKIN -> td_header[] = array(" " ," ");

		$ADMIN -> html = $SKIN -> table_head("留言列表");

		while($mes= $DB -> db_fetch_row())
		{
			$ADMIN -> html .= $SKIN -> table_row( array($mes['message_writer_title'],$mes['message_content']) );

		}
		$ADMIN -> html .= $SKIN ->table_end();
		$ADMIN -> output();
		return;

	}
	function caveat_list()
	{
		global $INCOME,$DB,$ADMIN,$SKIN;
		
		$ADMIN -> page_title="投诉与举报";
		$SKIN -> td_header[] = array("投诉人","15%");
		$SKIN -> td_header[] = array("被投诉商家","15%");
		$SKIN -> td_header[] = array("投诉时间","20%");
		$SKIN -> td_header[] = array("IP来源","");
		$SKIN -> td_header[] = array(" ","");

	   $start = $INCOME['st'] ? intval( $INCOME['st'] ) : 0;

	   $DB -> db_query( "SELECT count(*) as ct FROM biz_caveat ");

	   $row_count = $DB -> db_fetch_row();

	   $pages = $SKIN->build_pagelinks( array('TOTAL_POSS'  => $row_count['count'],
											   'PER_PAGE'    => 10,
											   'CUR_ST_VAL'  => $start,
											   'L_SINGLE'    => "一页",
											   'L_MULTI'     => "页：",
											   'BASE_URL'    => $this->base_url."?act=mes"."&code={$INCOME['code']}"
											   )
											);
   	    $query = "SELECT * FROM biz_caveat ORDER BY time DESC LIMIT $start,10";

	    $ADMIN -> html .= $SKIN -> table_head();
        $DB -> db_query($query);
		while ( $r = $DB->db_fetch_row() )
		{
			
			$str = $r['is_process']	? "<font color=red>(已处理)</font>"." <a href='?act=mes&code=process&ID={$r['id']}'>处理</a> | <a href='?act=mes&code=delc&ID={$r['id']}'>删除</a>":"<a href='?act=mes&code=process&ID={$r['id']}'>处理</a> | <a href='?act=mes&code=delc&ID={$r['id']}'>删除</a>";		
			$tm = date("Y-m-d H:i:s",$r['time']);
			$ADMIN->html .= $SKIN->table_row( array("{$r['writer']}","{$r['seller']}","{$tm}","{$r['ip']}","{$str}") );
		}

		$ADMIN->html .= $SKIN->td_basic($pages, 'right', 'pformstrip');
		$ADMIN->html .= $SKIN->table_end();
		$ADMIN->output();
		return;
	}
	function process_form()
	{
		global $INCOME,$DB,$ADMIN,$SKIN;

		$id = intval($INCOME['ID']);
		$DB -> db_query("SELECT * FROM biz_caveat WHERE id=".$id." LIMIT 1");
		$r = $DB -> db_fetch_row();
		$ADMIN -> page_title="处理投诉与举报";
		$ADMIN -> page_instruction = "‘公告形式公布’即是控制发布到前台公告栏目中。";
		$SKIN -> td_header[] = array(" ","15%");
		$SKIN -> td_header[] = array(""," ");
	    $ADMIN -> html .= $SKIN -> table_head("填写处理意见");
		$ADMIN -> html .= $SKIN -> form_head();
		$ADMIN -> html .= $SKIN -> form_input("code","doprocess","hidden");
		$ADMIN -> html .= $SKIN -> form_input("ID",$r[id],"hidden");
		$ADMIN -> html .= $SKIN -> table_row( array("投诉人",$r[writer]) );
		$ADMIN -> html .= $SKIN -> table_row( array("投诉人联系方式",$r[contact]) );
		$ADMIN -> html .= $SKIN -> table_row( array("被投诉商家",$r[seller]) );
		$ADMIN -> html .= $SKIN -> table_row( array("投诉内容",nl2br($r[content])) );
		$ADMIN -> html .= $SKIN -> table_row( array("处理意见","<TEXTAREA NAME='reply' ROWS='10' COLS='60'></TEXTAREA>") );
		$ADMIN -> html .= $SKIN -> table_row( array("是否以公告形式公布","<input type='checkbox' name='publish' value='1'>"));
		$ADMIN -> html .= $SKIN -> form_end(" 处 理 ");
		$ADMIN -> html .= $SKIN -> table_end();
		$ADMIN -> output();
		return;
	}
	function do_process()
	{
		global $DB,$INCOME,$ADMIN;
		$id = $INCOME['ID'];

		$DB -> db_query("SELECT * FROM biz_caveat WHERE id=".$id." LIMIT 1");
		$r = $DB -> db_fetch_row();
		$fomat= sprintf("%s\n%s\n%s\n%s\n%s\n%s\n%s","<b>投诉人：</b>".$r[writer],"<b>投诉时间：</b>".date("Y-m-d H:i:s",$r['time']),"<b>被投诉商家：</b>".$r[seller],"<b>投诉内容：</b>",$r[content],"<b>处理意见：</b>",$INCOME[reply] );
		if($INCOME['publish'])
		{
			$tm = time();
			$type = INFO_BRD;
			$DB -> db_query( "INSERT INTO `biz_info` ( `info_content` , `info_title` , `info_active_time` ,  `info_type` )  VALUES (  '{$fomat}', '投诉处理公告', '{$tm}',  '{$type}' )" );
		}

		$DB -> db_query("UPDATE biz_caveat SET is_process =1,reply='".$INCOME[reply]."' WHERE id=".$id);
		$ADMIN -> record_log("处理投诉");
		$ADMIN -> done_screen( "处理投诉成功","投诉与举报","act=mes&code=caveat");
		return;
	}
	function del_caveat()
	{
		global $DB,$ADMIN,$INCOME;
		$DB -> db_query("DELETE FROM biz_caveat WHERE id=".intval($INCOME[ID]) );
		$ADMIN -> record_log("删除处理投诉");
		$ADMIN -> done_screen( "删除投诉成功","投诉与举报","act=mes&code=caveat");
		return;

	}
}
?>